﻿namespace IBTrader.Indicator.Average
{
    using IBTrader.Modules.Read;
    using IBTrader.Charts;
    using System.Linq;
    
    abstract class XEMA: Base
    {
        protected readonly EMA[] emas;
        internal XEMA(Worker worker, IChartArgs chartArgs, params double[] intervals) : base(worker, chartArgs)
        {
            emas = intervals.Select(i => new EMA(worker, i)).ToArray();
            Init();
        }
        internal XEMA(Worker worker, params double[] intervals) : this(worker, new ChartArgs(), intervals) { }
        protected virtual void Init()
        {
            for (int i = 1; i < emas.Length; i++)
                emas[i - 1].Hit += emas[i].Add;
        }
        public override void Add(object sender, Line line)
        {
            emas[0].Add(sender, line);
        }
    }
}
